<?php

/**
 * AimUser form base class.
 *
 * @method AimUser getObject() Returns the current form's model object
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Hindua88
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAimUserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'        => new sfWidgetFormInputHidden(),
      'email'     => new sfWidgetFormInputText(),
      'full_name' => new sfWidgetFormInputText(),
      'password'  => new sfWidgetFormInputText(),
      'tel'       => new sfWidgetFormInputText(),
      'mobile'    => new sfWidgetFormInputText(),
      'address'   => new sfWidgetFormInputText(),
      'role'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AimRole'), 'add_empty' => true)),
      'is_active' => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'id'        => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'email'     => new sfValidatorString(array('max_length' => 128)),
      'full_name' => new sfValidatorString(array('max_length' => 120)),
      'password'  => new sfValidatorString(array('max_length' => 32)),
      'tel'       => new sfValidatorString(array('max_length' => 12, 'required' => false)),
      'mobile'    => new sfValidatorString(array('max_length' => 12, 'required' => false)),
      'address'   => new sfValidatorPass(array('required' => false)),
      'role'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AimRole'), 'required' => false)),
      'is_active' => new sfValidatorBoolean(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'AimUser', 'column' => array('email')))
    );

    $this->widgetSchema->setNameFormat('aim_user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'AimUser';
  }

}
